﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace EFCore1
{
  public class PersonConfig : IEntityTypeConfiguration<Person>
  {
    public void Configure(EntityTypeBuilder<Person> builder)
    {
      builder.ToTable("T_Persons");
       
      //builder.HasKey(x => x.Id); //设置主键
      builder.Property(a => a.Salary).HasDefaultValue(2000);//默认值
      builder.Property(a => a.BirthPlace).HasDefaultValue("中国");
      builder.HasIndex(a => a.Name); //设置索引
    }
  }
}
